package de.fhhof.XMLParser;

import java.util.List;
import java.util.Vector;

import org.jdom.Document;
import org.jdom.Element;

public class Book {

	Title title;
	Vector <String> authors = new Vector <String>();
	int year;
	double price;
	String category;
	
	public Book(String category) {
		super();
		this.category = category;
	}

	public Book(Element e) {
		this(e.getAttributeValue("category"));
		setPrice(new Double(e.getChild("price").getTextTrim()));
		setYear(new Integer(e.getChild("year").getTextTrim()));
		setTitle(new Title(e.getChild("title")));
		List <Element> authors	= e.getChildren("author");
		for(Element a : authors){
			addAuthor(a.getTextTrim());
		}
	}

	public Title getTitle() {
		return title;
	}

	public void setTitle(Title title) {
		this.title = title;
	}

	public Vector<String> getAuthor() {
		return authors;
	}

	public void addAuthor(String author) {
		authors.add(author);
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	
	
	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	@Override
	public String toString() {
		return "Book [title=" + title + ", authors=" + authors + ", year="
				+ year + ", price=" + price + ", category=" + category + "]";
	}
	
	
	
}
